﻿using SportsPlatform.Base;
using SportsPlatform.Query.SportBusiness.ProjectType;
using SportsPlatform.SportBusiness.ISportBusiness;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.Dto.SportBusiness.ProjectType;
using SportsPlatform.Filters;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 项目类别控制器
    /// </summary>
    [ActionAuthorization]
    [Route("api/[controller]/[action]")]

    public class ProjectTypeController : SportsPlatformControllerBase
    {
        private IProjectTypeService _projectTypeService;
        public ProjectTypeController(IProjectTypeService projectTypeService)
        {
            _projectTypeService = projectTypeService;
        }

        /// <summary>
        /// 添加项目类别
        /// </summary>
        /// <param name="addProjectTypeQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AddProjectType([FromBody] AddProjectTypeQuery addProjectTypeQuery)
        {
            return await _projectTypeService.AddProjectType(addProjectTypeQuery);
        }

        /// <summary>
        /// 获取所有项目类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultListDto<ProjectTypeDto>> GetAllProjectType()
        {
            return await _projectTypeService.GetALLType();
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="state">状态</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateState([FromBody] UpdateProjectTypeStateQuery state)
        {
            return await _projectTypeService.SetState(state);
        }

        /// <summary>
        /// 更新删除状态
        /// </summary>
        /// <param name="deleteProjectTypeQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateDeleteState([FromBody] DeleteProjectTypeQuery deleteProjectTypeQuery)
        {
            return await _projectTypeService.Delete(deleteProjectTypeQuery);
        }

        /// <summary>
        /// 客户端分页获取项目类别信息（用于信息同步）
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<GetPageProjectTypeKHDDto>> GetPageProjectTypeKHD([FromBody] BasePageQuery query)
        {
            return await _projectTypeService.GetPageProjectTypeKHD(query);
        }
    }
}
